<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { HttpStatusCode } from 'axios'
import { addDict } from '../../../../api/dict'

let formLabelAlign = reactive<Dict>({
  dict_name: '',
  dict_mark: '',
})

const emits = defineEmits(['increase', 'closeShow'])
const submitData = async () => {
  const res = await addDict(formLabelAlign)
  if(res.statusCode === HttpStatusCode.Created) {
    ElMessage({
      message: '添加成功',
      type: 'success',
    })
    emits('increase', 1, '')
    emits('closeShow')
  } else {
    ElMessage({
      message: '添加失败',
      type: 'error',
    })
  }
}
</script>

<template>
  <el-form
      label-position="top"
      label-width="100px"
      :model="formLabelAlign"
      style="max-width: 460px"
  >
    <el-form-item label="字典名称">
      <el-input v-model="formLabelAlign.dict_name" />
    </el-form-item>
    <el-form-item label="字典标识">
      <el-input v-model="formLabelAlign.dict_mark" />
    </el-form-item>
  </el-form>
  <el-button type="primary" @click="submitData">提交</el-button>
</template>

<style lang="less" scoped>

</style>
